package com.jomoo.css.common.util.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.jomoo.css.common.util.security.AuthenticationUser;
import lombok.*;

import java.sql.Timestamp;

@TableName(value = "t_base_file")
@JsonIgnoreProperties(ignoreUnknown = true)
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BaseFile {
    @TableId
    private Long id;

    @TableField("req_id")
    private String reqId;

    @TableField("req_type")
    private String reqType;

    @TableField("original_file_name")
    private String originalFileName;

    @TableField("unique_file_name")
    private String uniqueFileName;

    @TableField("subdirectory")
    private String subdirectory;

    @TableField("ext_name")
    private String extName;

    @TableField("create_user")
    private String createUser;

    @TableField("create_time")
    private Timestamp createTime;

    @TableField("update_user")
    private String updateUser;

    @TableField("update_time")
    private Timestamp updateTime;

    @TableField("version")
    private Integer version;

    public  BaseFileBuilder getSessionBuider() {
        AuthenticationUser authenticationUser = AuthenticationUser.getAuthenticationUser();
        return builder().updateTime(new Timestamp(System.currentTimeMillis()))
                .createTime(new Timestamp(System.currentTimeMillis()))
                .createUser(authenticationUser.getLoginName())
                .updateUser(authenticationUser.getLoginName());
    }
}
